/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var NewsProxy = function(baseUri) {
    this.baseUri = baseUri;
}

NewsProxy.prototype = (function() {
    return {
        find: function(id) {
            return $.getJSON(this.baseUri + "/" + id);
        },
        
        getAll: function() {
            return $.getJSON(this.baseUri);
        },
        
        add: function(newsItem) {
            return $.ajax({
                type: 'POST',
                url: this.baseUri,
                data: newsItem,
                async: false
            });
        },
        
        update: function(newsItem) {
            return $.ajax({
                type: 'PUT',
                url: this.baseUri,
                data: newsItem,
                async: false
            });
        },
        
        remove: function(id) {
            return $.ajax({
                type: 'DELETE',
                url: this.baseUri + "/" + id,
                async: false
            });
        }
    }
}());
